package com.ruoyi.strategy;

import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

@Service
public class FeeCalculationService {
	HashMap<String, DiscountStragegy> map= new HashMap<>();

	public FeeCalculationService(List<DiscountStragegy> discountStragegies){
		for (DiscountStragegy discountStrategy: discountStragegies) {
			map.put(discountStrategy.type(),discountStrategy);
		}
	}

	public double calculate(String type,double cost){
		return map.get(type).discount(cost);
	}
}
